home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWGVector.z / RWGVector
Encoding:
Text File  |  1998-10-30  |  7.3 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                                RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWGVector(val) - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/gvector.h>
  13.  
  14.  
  15.  
  16.               declare(RWGVector,vvvvaaaallll)
  17.           implement(RWGVector,vvvvaaaallll)
  18.           RWGVector(vvvvaaaallll) a;   // A Vector of vvvvaaaallll''''ssss.
  19.  
  20.  
  21.  
  22.  
  23. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  24.      Class RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((vvvvaaaallll)))) represents a group of ordered elements, accessible
  25.      by an index.  Duplicates are allowed. This class is implemented as an
  26.      array.  Objects of type RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((vvvvaaaallll)))) are declared with macros defined
  27.      in the standard C++ header file <<<<ggggeeeennnneeeerrrriiiicccc....hhhh>>>>. Note that it is a vvvvaaaalllluuuueeee----
  28.      bbbbaaaasssseeeedddd collection: items are copied in and out of the collection.  The
  29.      class vvvvaaaallll must have:
  30.           a default constructor;
  31.  
  32.           well-defined copy semantics (vvvvaaaallll::::::::vvvvaaaallll((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or equiv.);
  33.  
  34.           well-defined assignment semantics (vvvvaaaallll::::::::ooooppppeeeerrrraaaattttoooorrrr====((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or
  35.           equivalent).
  36.  
  37.  
  38. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  39.      For each type of RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr, you must include one (and only one) call to
  40.      the macro iiiimmmmpppplllleeeemmmmeeeennnntttt, somewhere in your code.  None
  41.  
  42. EEEExxxxaaaammmmpppplllleeee
  43.               #include <rw/gvector.h>
  44.  
  45.  
  46.  
  47.               #include <rw/rwdate.h>
  48.           #include <rw/rstream.h>
  49.  
  50.  
  51.               declare(RWGVector, RWDate)   /* Declare a vector of dates */
  52.  
  53.  
  54.  
  55.               implement(RWGVector, RWDate) /* Implement a vector of dates */
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                                RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               main()  {
  75.  
  76.  
  77.  
  78.                 RWGVector(RWDate) oneWeek(7);
  79.             for (int i=1; i<7; i++)
  80.               oneWeek(i) = oneWeek(0) + i;
  81.  
  82.  
  83.                 for (i=0; i<7; i++)
  84.  
  85.  
  86.  
  87.                   cout << oneWeek(i) << endl;
  88.  
  89.  
  90.  
  91.                 return 0;
  92.  
  93.  
  94.  
  95.               }
  96.  
  97.      Program output:
  98.  
  99.               04/12/93
  100.           04/13/93
  101.           04/14/93
  102.           04/15/93
  103.           04/16/93
  104.           04/17/93
  105.  
  106. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  107.      04/18/93
  108.  
  109.  
  110.  
  111.               RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((vvvvaaaallll))))();
  112.  
  113.  
  114.      Construct an empty vector.
  115.  
  116.               RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((vvvvaaaallll))))(size_t n);
  117.  
  118.  
  119.      Construct a vector with length nnnn. The initial values of the elements can
  120.      (and probably will) be garbage.
  121.  
  122.               RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((vvvvaaaallll))))(size_t n, vvvvaaaallll v);
  123.  
  124.  
  125.      Construct a vector with length nnnn. Each element is assigned the value vvvv.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                                RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((vvvvaaaallll))))(RWGVector(vvvvaaaallll)& s);
  141.  
  142.  
  143.      Copy constructor.  The entire vector is copied, including all embedded
  144.      values.
  145.  
  146. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  147.               RWGVector(val)&
  148.           ooooppppeeeerrrraaaattttoooorrrr====(RWGVector(vvvvaaaallll)& s);
  149.  
  150.  
  151.      Assignment operator.  The entire vector is copied.
  152.  
  153.               RWGVector(vvvvaaaallll)&
  154.           ooooppppeeeerrrraaaattttoooorrrr====(vvvvaaaallll v);
  155.  
  156.  
  157.      Sets all elements of self to the value vvvv.
  158.  
  159.               vvvvaaaallll
  160.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i) const;
  161.           vvvvaaaallll&&&&
  162.           ooooppppeeeerrrraaaattttoooorrrr()(size_t i);
  163.  
  164.  
  165.      Return the iiii'th element in the vector.  The index iiii must be between zero
  166.      and the length of the vector less one.  No bounds checking is performed.
  167.      The second variant can be used as an lvalue.
  168.  
  169.               vvvvaaaallll
  170.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i) const;
  171.           vvvvaaaallll&&&&
  172.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
  173.  
  174.  
  175.      Return the iiiith element in the vector.  The index iiii must be between zero
  176.      and the length of the vector less one.  Bounds checking is performed.
  177.  
  178. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  179.               const val*
  180.           ddddaaaattttaaaa() const;
  181.  
  182.  
  183.      Returns a pointer to the raw data of self.  Should be used with care.
  184.  
  185.               size_t
  186.           lllleeeennnnggggtttthhhh() const;
  187.  
  188.  
  189.      Returns the length of the vector.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                                RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               void
  207.           rrrreeeesssshhhhaaaappppeeee(size_t n);
  208.  
  209.  
  210.      Resize the vector.  If the vector shrinks, it will be truncated.  If the
  211.      vector grows, then the value of the additional elements will be
  212.      undefined.
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.